package com.apes.fn.ssm.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.scm.masterdata.product.model.Brand;
import com.apes.scm.masterdata.product.model.Category;
import com.apes.scm.masterdata.product.model.Product;
import com.apes.scm.masterdata.stock.model.Location;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @ClassName : CalculateProduct
 * @Description : 测算商品
 * @Author : WSl
 * @Date: 2022-6-21 10:37
 */

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = CalculateProduct.CONST_TABLE_NAME)
public class CalculateProduct extends Model {

    public final static String CONST_TABLE_NAME = "mas_calculate_product";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "测算商品")
    @Comment("编码")
    private String id;

    @NotNull
    @Column(name = "location_id", length = 20)
    @Comment("仓库")
    private String location;

    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "fitting_message_id", referencedColumnName = "id")
    @Comment(value = "组合配件")
    private FittingMessage fittingMessage;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "product_id", referencedColumnName = "id")
    @Comment("商品")
    private Product product;

    @Column(name = "brand_priority_id", length = 20)
    @Comment("品牌优先级")
    private String brandPriority;

    @Column(name = "brand_id", length = 20)
    @Comment("品牌")
    private String brand;

    @Column(name = "oem_id", length = 200)
    @Comment("oem码")
    private String oemId;

    @Column(name = "category_id", length = 20)
    @Comment("商品类目")
    private String category;  //商品类目
}
